<template>
    <section class="client-ducoment">
        <riskControlStatistics/>
        <section class="common-block-section">
            <header class="top-line">
                <el-button
                    @click="openDialog(null)"
                    icon="el-icon-plus"
                    type="primary"
                    size="small">
                    刷新
                </el-button>
            </header>
            <el-table
                :data="tableData"
                style="width: 100%">
                <el-table-column
                    prop="serialNumber"
                    label="编号"
                    min-width="60">
                </el-table-column>
                <el-table-column
                    prop="companyName"
                    label="公司名称"
                    min-width="150">
                </el-table-column>
                <el-table-column
                    prop="payTaxesType"
                    label="纳税人类型"
                    min-width="90">
                </el-table-column>
                <el-table-column
                    prop="accountingManager"
                    label="联系人"
                    min-width="90">
                </el-table-column>
                <el-table-column
                    prop="mobile"
                    label="电话号码"
                    min-width="120">
                </el-table-column>
                <el-table-column
                    prop="weChartAccount"
                    label="联系人微信号"
                    min-width="90">
                </el-table-column>
                <el-table-column
                    label="风险评估"
                    min-width="260">
                    <template class="tags" slot-scope="scope">
                        <el-tag v-for="(level, index) in scope.row.riskLevel"
                        :key="index"
                        :type="getTypeFromLevel(level)"
                        effect="dark">
                        {{level}}
                        </el-tag>
                    </template>
                </el-table-column>
                 <el-table-column
                    label="操作"
                    min-width="100">
                    <template slot-scope="scope">
                        <el-button v-if="scope.row.riskLevel[0] != '税负率无风险'"
                        type="primary"
                        @click="openDialog(scope.row)">
                        查看详情
                        </el-button>
                    </template>
                </el-table-column>
            </el-table>
            <el-pagination
                background
                layout="prev, pager, next"
                :total="total"
                :current-page.sync="currentPage"
                :page-size.sync="pageSize"
                class="pagination">
            </el-pagination>
        </section>
        <company-dialog ref="dialog"/>
    </section>
</template>

<script>
/**
 * @file 客户档案
 */
import map from '@/components/map';
import riskControlStatistics from './components/riskControlStatistics';
import dialog from './taxdialog.vue';

export default {
    components: {
        riskControlStatistics,
        companyDialog: dialog
    },
    data() {
        return {
            companyName: '',
            industry: '',
            payTaxesType: '',
            industryList: map.industryList,
            payTaxesTypeList: map.payTaxesTypeList,
            total: 0,
            tableData: [],
            multipleSelection: [],
            currentPage: 1,
            pageSize: 20
        };
    },
    mounted() {
        this.tableData = [{
            serialNumber:1,
            companyName:"德昌县蔬菜藏业开发有限公司",
            payTaxesType:"小规模纳税人",
            accountingManager: "刘千芳",
            mobile: "13051810202",
            weChartAccount: "Yly345662",
            riskLevel: ["税负率偏低", "毛利率偏高"]
        },{
            serialNumber:2,
            companyName:"德昌湧鑫钒业有限公司",
            payTaxesType:"小规模纳税人",
            accountingManager: "象述戈",
            mobile: "15708498737",
            weChartAccount: "BGY3713912",
            riskLevel: ["税负率偏低", "毛利率偏高"]
        },{
            serialNumber:3,
            companyName:"德昌奥帆商贸有限公司",
            payTaxesType:"小规模纳税人",
            accountingManager: "宋吉林",
            mobile: "13981516195",
            weChartAccount: "13981516195",
            riskLevel: ["税负率无风险"]
        },{
            serialNumber:4,
            companyName:"攀枝花尊永商贸有限公司",
            payTaxesType:"小规模纳税人",
            accountingManager: "余德崇",
            mobile: "13980281675",
            weChartAccount: "13980281675",
            riskLevel: ["税负率无风险"]
        },{
            serialNumber:5,
            companyName:"西昌长丰茶府",
            payTaxesType:"小规模纳税人",
            accountingManager: "王刚",
            mobile: "15532739282",
            weChartAccount: "15532739282",
            riskLevel: ["税负率无风险"]
        },{
            serialNumber:6,
            companyName:"德昌旭瑞物流部",
            payTaxesType:"小规模纳税人",
            accountingManager: "李瑞",
            mobile: "13076589896",
            weChartAccount: "qwe3456",
            riskLevel: ["税负率无风险"]
        },{
            serialNumber:7,
            companyName:"德昌久钒矿业有限公司",
            payTaxesType:"小规模纳税人",
            accountingManager: "吴艾琳",
            mobile: "13165498281",
            weChartAccount: "asdfgh321",
            riskLevel: ["税负率无风险"]
        },{
            serialNumber:8,
            companyName:"德昌雪岭山泉有限公司",
            payTaxesType:"小规模纳税人",
            accountingManager: "李念新",
            mobile: "13826253434",
            weChartAccount: "13826253434",
            riskLevel: ["税负率无风险"]
        }];
    },
    methods: {
        getTypeFromLevel(level){
            if (level=="税负率无风险"){
                return "success"
            }else if (level == "税负率偏低"){
                return "danger"
            }else if (level=="毛利率偏高"){
                return "danger"
            }
        },
        openDialog(companyData) {
            this.$refs.dialog.open(companyData);
        },
    }
}
</script>

<style lang="less" scoped>
.client-ducoment {
    padding: 0 10px;
    .pagination {
        text-align: right;
        padding: 20px 0 0;
    }
}
.tags{
    text-align: center;
}
.el-tag{
    margin-left: 2%;
    margin-right: 2%;
}
</style>
